<template>
	<view>
		<pickerModule :picker="item" v-for="(item, index) in picker" :key="index" @pickerChange="pickerChange"></pickerModule>
		<baseForm :column.sync="column" @submitFun="submitFun" :submitStatus="submitDisable" :button="button"></baseForm>
		<progressBox :auditVos="auditVos" dictcode="dict_audit_status"></progressBox>
		<view class="buttons" v-if="getApprovalShow('applyStatus')">
			<button size="mini" class="middleButton" @click="pass('报修', itemData)">已处理</button>
			<!-- <button size="mini" class="middleButton" @click="unpass('用车', itemData)">未处理</button> -->
		</view>
	</view>
</template>

<script>
import baseForm from '@/wxcomponents/form/form.vue';
import pickerModule from '@/wxcomponents/form/picker.vue';
import { format, dectList } from '@/libs/common.js';
import progressBox from '@/wxcomponents/commonLayout/progressLevel.vue';
import userMixins from '@/libs/userMixins.js'
import approvalMixins from '@/libs/approvalMixins.js'
import formMixins from '@/libs/formMixins.js'
export default {
	mixins: [userMixins, approvalMixins, formMixins],
	data() {
		return {
			itemData: '',
			button: {
				hide: true
			},
			column: [
				{
					label: '报修日期',
					name: 'applyDate',
					type: 'picker',
					mode: 'date',
					required: true,
					disabled: true,
					value: format('YY-mm-dd', new Date()),
					text: format('YY-mm-dd', new Date())
				},
				{
					label: '故障位置',
					name: 'malfunctionLocation',
					type: 'normalInput',
					disabled: true,
					required: true,
					value: ''
				},
				{
					label: '报修内容',
					name: 'applyDetails',
					type: 'normalInput',
					disabled: true,
					required: true,
					value: ''
				}
			],
			detailId: '',
			auditVos:""
		};
	},
	async onLoad(option) {
		this.itemData = JSON.parse(option.data);
		this.getDetail();
	},
	methods: {
		
		async getDetail() {
			let self = this;
			let caseMap = [
				{
					condition() {	// 详情
						return self.itemData.detailType == 'detail'
					},
					async func() {
						let resp = await self.$http.get({
							url: `/oa/wechat/repairsApply/detail/${self.itemData.id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						self.auditVos = resp.result.auditVos;
						
					}
				},
				{
					condition() {	// 审批
						return self.itemData.detailType == 'approval'
					},
					async func() {
						let resp = await self.$http.get({
							url: `/oa/wechat/repairsApply/detail/${self.itemData.id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						self.auditVos = resp.result.auditVos;
						
					}
				},
			]
			let findOne = caseMap.filter(item => {
				return item.condition()
			})[0]
			console.log(findOne)
			if (!findOne) {
				alert(`getDetail方法出错`)
			}
			findOne.func();
		}
	},
	components: {
		baseForm,
		pickerModule,
		progressBox
	},
	watch: {}
};
</script>

<style></style>
